package com.huike.report.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Description ReportMapper
 * @Author chenjialiang
 * @Date 2023-10-17
 */
@Mapper
public interface ReportMapper {
    @Select("select count(*) from tb_business left join tb_activity ta on tb_business.activity_id = ta.id where ta.code = #{code}")
    Integer getBusinessNum(String code);

    @Select("select count(*) from tb_clue left join tb_activity ta on tb_clue.activity_id = ta.id where ta.code = #{code}")
    Integer getCluesNum(String code);

    @Select("select sum(tb_contract.course_price) - sum(tb_contract.contract_order) from tb_contract left join tb_activity ta on tb_contract.activity_id = ta.id where ta.code =#{code}")
    Double getCost(String code);

    @Select("select sum(tb_contract.contract_order) from tb_contract left join tb_activity ta on tb_contract.activity_id = ta.id where ta.code = #{code}")
    Double getAmount(String code);

    @Select("select count(*) from tb_contract left join tb_activity ta on tb_contract.activity_id = ta.id where ta.code =#{code}")
    Integer getCCustomersNum(String code);

    @Select("select count(*) from tb_clue left join tb_activity ta on tb_clue.activity_id = ta.id where tb_clue.status=1 and ta.code = #{code}")
    Integer getFalseCluesNum(String code);
}
